import java.io.*;
import java.nio.file.*;
import java.util.*;

public class LanQiao {
    public static void main(String[] args) {

                String input = "aaaabbbbccccc";

                // 转换为小写确保字母一致性
                input = input.toLowerCase();

                // 创建26个字母的计数数组（索引0=a, 1=b, ... 25=z）
                int[] letterCounts = new int[26];

                // 遍历字符串统计字母频率
                for (char c : input.toCharArray()) {
                    // 只处理a-z的小写字母
                    if (c >= 'a' && c <= 'z') {
                        int index = c - 97;  // 计算字母在数组中的索引
                        letterCounts[index]++;
                    }
                }

                // 找出最大频率值
                int maxCount = 0;
                for (int count : letterCounts) {
                    if (count > maxCount) {
                        maxCount = count;
                    }
                }

                // 找出所有达到最大频率的字母
                System.out.print("出现次数最多的字母: ");
                for (int i = 0; i < letterCounts.length; i++) {
                    if (letterCounts[i] == maxCount) {
                        char letter = (char)('a' + i);
                        System.out.print(letter + " ");
                    }
                }

                System.out.println("\n出现次数: " + maxCount);
            }



    //计算最大异或数目
    public static int countChar(char[] chars) {
        int s1 = 0;
        int s0 = 0;
        for (char ch : chars) {
            if (ch == '0') {
                s1++;
            } else {
                s0++;
            }
        }
        return Math.min(s1, s0);
    }

    //合并两个数组
    public static int[] merge(int[] nums1, int[] nums2, int n, int m) {
        int[] arrs = new int[n];
        for (int i = 0; i < m; i++) {
            arrs[i] = nums1[i];
        }
        for (int i = 0; i < nums2.length; i++) {
            arrs[i + m] = nums2[i];
        }
        Arrays.sort(arrs);
        return arrs;
    }

    //字符串匹配
    private static String order(String str) {
        char[] chars = str.toCharArray();
        Arrays.sort(chars);
        return new String(chars);
    }

    //读取文件
    public static List<String> parseFile(String path) throws IOException {
        List<String> nums = new ArrayList<>();
        // 读取文件中的所有行
        List<String> sections = Files.readAllLines(Paths.get(path));

        // 按逗号分割
        for (String section : sections) {
            String[] split = section.split(",");
            //并去除空格
            for (String s : split) {
                nums.add(s.trim());
            }
        }
        return nums;
    }

    //算最大公约数
    // gcd
    public static long gcd(long a, long b) {
        while (b != 0) {
            long t = b;
            b = a % b;
            a = t;
        }
        return a;
    }

    //最小公约数
    public static long lcm(long a, long b) {
        return a * b / gcd(a, b);
    }

    //质数
    public static boolean isPrime(int n) {
        if (n <= 1) return false;
        if (n <= 3) return true;
        if (n % 2 == 0 || n % 3 == 0) return false;
        for (int i = 5; i * i <= n; i += 6) {
            if (n % i == 0 || n % (i + 2) == 0) return false;
        }
        return true;
    }

    //最长回文
    public static int[] extend(String str, int left, int right) {
        //如果是回文，扩大范围
        while (left >= 0 && right < str.length() && str.charAt(left) == str.charAt(right)) {
            left--;
            right++;
        }
        //不是回文
        return new int[]{left, right};
    }

    //判断是否回文
    public static boolean isPalindrome(String s) {
        // 步骤1：手动过滤非字母数字字符，并转为小写
        StringBuilder sb = new StringBuilder();
        for (char c : s.toCharArray()) {
            // 直接判断是否是字母或数字
            if (Character.isLetterOrDigit(c)) {
                //统一转为大写
                sb.append(Character.toLowerCase(c));
            }
        }
        // 步骤2：双指针判断回文
        int left = 0, right = s.length() - 1;
        while (left < right) {
            if (sb.charAt(left) != sb.charAt(right)) {
                return false;
            }
            left++;
            right--;
        }
        return true;
    }
}